package com.heima.admin.controller.v1;

import com.heima.apis.wemedia.IWemediaClient;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.WmChannelPageReqDto;
import com.heima.model.wemedia.pojos.WmChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController {

    @Autowired
    private IWemediaClient wemediaClient;

    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel){
        ResponseResult result = wemediaClient.updateChannel(wmChannel);
        return result;
    }

    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel){
        ResponseResult result = wemediaClient.saveChannel(wmChannel);
        return result;
    }

    @GetMapping("/del/{id}")
    public ResponseResult delChannel(@PathVariable Integer id){
        ResponseResult result = wemediaClient.delChannel(id);
        return result;
    }

    @PostMapping("/list")
    public ResponseResult findListFromChannel(@RequestBody WmChannelPageReqDto dto){
        ResponseResult result = wemediaClient.findChannelList(dto);
        return  result;
    }
}
